//
//  PromptTableViewCell.m
//  Runone
//
//  Created by runone01 on 16/9/6.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "PromptTableViewCell.h"
#import "RequestHelper.h"
#import "MJExtension.h"
#import "AppLocalManager.h"
#import "Define.h"
#import "SysPersonalSettingInfoModel.h"

@implementation PromptTableViewCell

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
    
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];

}

- (IBAction)request:(UISwitch *)sender {
        if (sender.on) {
            _state = true;
        }
        else
        {
            _state = false;
        }
    
    switch (_switchBtn.tag) {
        case 0:
            _model.highwaysVehicleAlarm = _state;

            break;
        case 1:
            _model.administrativeVehicleAlarm = _state;// 行政车辆告警

            break;
        case 2:
            _model.trafficAccidentAlarm = _state;// 交通事故告警

            break;
        case 3:

            _model.constructionEventAlarm = _state;// 施工事件告警

            break;
        case 4:
            
            _model.busDangerousAlarm = _state;// 施工事件告警
            
            break;
        case 5:
            
            _model.curingVehicleAlarm = _state;// 施工事件告警
            
            break;
        case 6:
            _model.rescueVehicleAlarm = _state;// 施工事件告警
            
            break;
        default:
            break;
    }

    [self request];
        
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
//刷新数据
-(void)request {
    RequestHelper *requestHelper=[[RequestHelper alloc] init];
    
    RequestGinsengModel *getCurrentEventModel=[[RequestGinsengModel alloc] init];
    getCurrentEventModel.URL         = GetCurrentDutyPersonalName;
    getCurrentEventModel.DataValue   = [self jsonstring];
    getCurrentEventModel.UpdatedTime = [requestHelper getCurrentTime];
    getCurrentEventModel.SystemCode  = @"GuangleHighway";
    getCurrentEventModel.MethodName  = @"SaveSysPersonalSettingInfo";
    
    requestHelper.block=^(RequestOutginseng *requestOutginseng,id dataValueModel){

    };
    
    [requestHelper RequestGinsengModel:getCurrentEventModel andPushController:nil];
}

-(NSString *)jsonstring {
    _KVModel=[[ParModel alloc] init];
    SysPersonalSettingInfoModel *pushModel=[[SysPersonalSettingInfoModel alloc] init];
    pushModel=_PushModel;
   
    NSMutableDictionary *TempDic=_model.mj_keyValues;
    NSString *tempStr = [TempDic mj_JSONString];
   
    pushModel.AlarmContent = tempStr;
    
    NSMutableDictionary *dic=pushModel.mj_keyValues;
    NSString *temp=[dic mj_JSONString];
    _KVModel.key=@"SysPersonalSettingInfo";
    _KVModel.value=temp;
    
    NSMutableDictionary *dicc=_KVModel.mj_keyValues;
    NSString *dateValue=[dicc mj_JSONString];
    NSString *str=@"[";
    NSString *tempp=[str stringByAppendingString:dateValue];
    NSString *str1=@"]";
    NSString *JsonString=[tempp stringByAppendingString:str1];
    return JsonString;
    
}
@end
